(*
 * This file is part of MONPOLY.
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * Contact:  Nokia Corporation (Debmalya Biswas: debmalya.biswas@nokia.com)
 * 
 * Copyright (C) 2012 ETH Zurich.
 * Contact:  ETH Zurich (Eugen Zalinescu: eugen.zalinescu@inf.ethz.ch)
 * 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, version 2.1 of the
 * License.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * http://www.gnu.org/licenses/lgpl-2.1.html.
 *
 * As a special exception to the GNU Lesser General Public License,
 * you may link, statically or dynamically, a "work that uses the
 * Library" with a publicly distributed version of the Library to
 * produce an executable file containing portions of the Library, and
 * distribute that executable file under terms of your choice, without
 * any of the additional requirements listed in clause 6 of the GNU
 * Lesser General Public License. By "a publicly distributed version
 * of the Library", we mean either the unmodified Library as
 * distributed by Nokia, or a modified version of the Library that is
 * distributed under the conditions defined in clause 3 of the GNU
 * Lesser General Public License. This exception does not however
 * invalidate any other reasons why the executable file might be
 * covered by the GNU Lesser General Public License.
 *)



(** This module defines tables (named relations).
    
    A table has a name and consists of a relation and a sequence of
    attributes naming the columns of the relation.
*)

open Predicate
open Relation

type schema = var * (string * tcst) list
  (** A schema consists of name and a sequence (here a list) of
      attribute names and types. *)


type table
  (** A table is a schema and a relation over that schema. *)



val make_table: schema -> relation -> table
  (** [make_table s rel] build a table from schema [s] and relation
      [rel] *)

val get_schema: table -> schema
  (** [get_schema tb] returns the schema of table [tb]. *)

val get_relation: table -> relation
  (** [get_relation tb] returns the relation of table [tb]. *)


val get_matches: (var list) -> (var list) -> (int * int) list
  (** The arguments of [get_matches] are two lists of
      attributes. [get_matches attr1 attr2] returns the maximal list
      of pairs [(pos2,pos1)] where the attribute at position [pos2] in
      [attr2] is found at position [pos1] in [attr1]. 

      For instance, [get_matches ["a";"b";"d"] ["b";"d";"e";"a"]]
      returns [[(0,1);(1,2);(3,0)]]. 
  *)



(** Pretty-printing functions: *)

val print_schema: string -> schema -> unit
val print_table: table -> unit
val dump_table: table -> unit


